package designPattern.creation.prototypepattern;

import java.util.ArrayList;

/**
 * @author 张琪
 * @date 2023/1/30 15:55
 */
public class DeepClone extends Prototype{
    @Override
    public void show() {
        System.out.println("深克隆");
    }

    @SuppressWarnings("unchecked")
    @Override
    public Prototype clone(){
        Prototype prototype = null;
        try {
            prototype = (Prototype) super.clone();
        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
        }
        prototype.list = (ArrayList<String>) this.list.clone();
        return prototype;
    }
}
